import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '客户名称',
    align:"center",
    sorter: true,
    dataIndex: 'customerName'
   },
   {
    title: '联系人',
    align:"center",
    sorter: true,
    dataIndex: 'contacts'
   },
   {
    title: '联系电话',
    align:"center",
    sorter: true,
    dataIndex: 'contactNumber'
   },
   {
    title: '上门地址',
    align:"center",
    sorter: true,
    dataIndex: 'homeAddress',
   },
   {
    title: '详细地址',
    align:"center",
    sorter: true,
    dataIndex: 'address'
   },
   {
    title: '所属网点',
    align:"center",
    dataIndex: 'affiliatedBranch'
   },
   {
    title: '设备数量',
    align:"center",
    dataIndex: 'devicesNumber'
   },
   {
    title: '工单数量',
    align:"center",
    dataIndex: 'workOrderQuantity'
   },
   {
    title: '到期时间',
    align:"center",
    dataIndex: 'expirationTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '添加时间',
    align:"center",
    dataIndex: 'createTime'
   },
   {
    title: '规模',
    align:"center",
    dataIndex: 'scale'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remarks'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "客户名称",
      field: 'customerName',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "联系人",
      field: 'contacts',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "联系电话",
      field: 'contactNumber',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "详细地址",
      field: 'address',
      component: 'Input',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '客户名称',
    field: 'customerName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入客户名称!'},
          ];
     },
  },
  {
    label: '联系人',
    field: 'contacts',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入联系人!'},
          ];
     },
  },
  {
    label: '联系电话',
    field: 'contactNumber',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入联系电话!'},
                 { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
          ];
     },
  },
  {
    label: '上门地址',
    field: 'homeAddress',
    defaultValue: ['520000', '522600', '522601'],
    component: 'JAreaLinkage',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入上门地址!'},
          ];
     },
  },
  {
    label: '详细地址',
    field: 'address',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入详细地址!'},
          ];
     },
  },
  {
    label: '到期时间',
    field: 'expirationTime',
    component: 'DatePicker',
  },
  {
    label: '规模',
    field: 'scale',
    component: 'Input',
  },
  {
    label: '备注',
    field: 'remarks',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  customerName: {title: '客户名称',order: 0,view: 'text', type: 'string',},
  contacts: {title: '联系人',order: 1,view: 'text', type: 'string',},
  contactNumber: {title: '联系电话',order: 2,view: 'text', type: 'string',},
  homeAddress: {title: '上门地址',order: 3,view: 'pca', type: 'string',},
  address: {title: '详细地址',order: 4,view: 'text', type: 'string',},
  affiliatedBranch: {title: '所属网点',order: 5,view: 'text', type: 'string',},
  devicesNumber: {title: '设备数量',order: 6,view: 'number', type: 'number',},
  workOrderQuantity: {title: '工单数量',order: 7,view: 'number', type: 'number',},
  expirationTime: {title: '到期时间',order: 8,view: 'date', type: 'string',},
  createTime: {title: '添加时间',order: 9,view: 'datetime', type: 'string',},
  scale: {title: '规模',order: 10,view: 'text', type: 'string',},
  remarks: {title: '备注',order: 11,view: 'textarea', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}